package core;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RandomGenerator {
	private static Random randomObject = new Random(1);

	
	public static void setSeed(int seed){
		randomObject = new Random(seed);
	}
	
	public static int getRandomValue(int min,int max){
		int randomValue = min+randomObject.nextInt(max-min+1);
		return randomValue;
	}
	
	/**
	 * Shuffles the list
	 * @param <E>
	 * @param list
	 * @return
	 */
	public static <E> void  shuffle(List<E> list){
		List<E> newList = new ArrayList<E>();
		while(!list.isEmpty()){
			E element = list.get(getRandomValue(0, list.size()-1));
			list.remove(element);
			newList.add(element);
			
		}
		
		list.addAll(newList);
	}

	
}
